package uk.org.landeg.euler.problems;

import java.io.BufferedReader;
import java.io.FileReader;
import java.math.BigInteger;

import uk.org.landeg.euler.problems.framework.AbstractProblem;
import uk.org.landeg.euler.problems.framework.ProblemLauncher;

public class Problem013 extends AbstractProblem {
	public static void main(String[] args) {
		ProblemLauncher launcher = new ProblemLauncher(new Problem013());
		launcher.solve();
	}
	@Override
	public String getDescription() {
		// TODO Auto-generated method stub
		return "Work out the first ten digits of the sum of the following one-hundred 50-digit numbers";
	}

	@Override
	public Integer getProblemNumber() {
		// TODO Auto-generated method stub
		return 13;
	}

	@Override
	public Object solve() {
		BigInteger total = BigInteger.valueOf(0L);
		try {
			BufferedReader reader = new BufferedReader (new FileReader("data/problem013.txt"));
			String line;
			while ((line = reader.readLine()) != null) {
				total = total.add(new BigInteger(line));
			}
		} catch (Exception e) {
			return e;
		}
		return total.toString().subSequence(0, 10);
	}

}
